import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shenfuhui/config/config.dart';

import '../routers/routers.dart';
import '../views/dialog_manager.dart';

///
/// 选择收货地址
///
class MineAddressChoose extends StatefulWidget {
  const MineAddressChoose({Key? key}) : super(key: key);

  @override
  State<MineAddressChoose> createState() => _MineAddressChooseState();
}

class _MineAddressChooseState extends State<MineAddressChoose> {
  var datas = [];

  @override
  void initState() {
    // TODO: implement initState
    setState(() {
      datas.add('');
      datas.add('');
      datas.add('');
    });
  }

  ///
  /// 返回普通的列表item
  ///
  Widget getListItem(int index) {
    return Container(
      margin: EdgeInsets.symmetric(vertical: 10.w, horizontal: 25.w),
      decoration: BoxDecoration(
        color: (Config.colorWhite),
        borderRadius: BorderRadius.circular(10.w),
      ),
      width: double.infinity,
      padding: EdgeInsets.symmetric(vertical: 20.w, horizontal: 25.w),
      child: InkWell(
        onTap: () {
          Routes.router.pop(context);
        },
        child: Column(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    Text(
                      "大飞哥哥",
                      style:
                          TextStyle(fontSize: 24.sp, color: Config.colorText1),
                    ),
                    Opacity(
                      opacity: index == 0 ? 1 : 0,
                      child: Container(
                        decoration: BoxDecoration(
                          color: Config.colorMain,
                          borderRadius: BorderRadius.circular(20.w),
                        ),
                        padding: EdgeInsets.symmetric(
                            vertical: 3.w, horizontal: 10.w),
                        margin: EdgeInsets.only(left: 14.w),
                        child: Text(
                          "默认",
                          style: TextStyle(
                              fontSize: 16.sp, color: Config.colorWhite),
                        ),
                      ),
                    ),
                  ],
                ),
                Text(
                  "18088550000",
                  style: TextStyle(fontSize: 24.sp, color: Config.colorText1),
                ),
              ],
            ),
            Padding(
              padding: EdgeInsets.only(top: 20.w),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Icon(
                  Icons.location_on_outlined,
                  size: 32.w,
                  color: Config.colorText1,
                ),
                Expanded(
                  child: Text(
                    "广东省深圳市宝安区新安街道47区和丰小区一巷4号",
                    style: TextStyle(fontSize: 24.sp, color: Config.colorText1),
                  ),
                ),
              ],
            ),
            Padding(
              padding: EdgeInsets.only(top: 15.w),
            ),
          ],
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Config.colorBg2,
        appBar: AppBar(
          title: const Text('选择收货地址'),
          centerTitle: true,
          actions: <Widget>[
            IconButton(
              icon: const Icon(Icons.add_location_alt_outlined),
              tooltip: '管理',
              onPressed: () {
                Routes.navigateTo(context, Routes.mineAddressManager);
              },
            ),
          ],
        ),
        body: SizedBox(
          width: double.infinity,
          height: double.infinity,
          child: ListView.builder(
            shrinkWrap: true,
            physics: const BouncingScrollPhysics(),
            itemCount: datas.length,
            padding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 0.w),
            itemBuilder: (BuildContext context, int index) {
              return getListItem(index);
            },
          ),
        ));
  }
}
